package com.gitee.eureka;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication
@EnableEurekaServer
@Slf4j
public class EurekaApplication1 {

	public static void main(String[] args) throws UnknownHostException {
	    SpringApplication app = new SpringApplication(EurekaApplication1.class);

	    Environment env = app.run(args).getEnvironment();
	    String protocol = "http";

	    log.info("\n----------------------------------------------------------\n\t" +
	                    "Application '{}' is running! Access URLs:\n\t" +
	                    "Local: \t\t{}://localhost:{}\n\t" +
	                    "External: \t{}://{}:{}\n\t" +
	                    "ApiDocs: \t{}\n" +
	                    "ContextPath: \t{}\n----------------------------------------------------------",
	            env.getProperty("spring.application.name"),
	            protocol,
	            env.getProperty("server.port"),
	            protocol,
	            InetAddress.getLocalHost().getHostAddress(),
	            env.getProperty("server.port"),
	            env.getProperty("application.doc"),
	            env.getProperty("server.servlet.context-path")
	    );
	}

}
